//
//  WKCommentView.m
//  WKMaybell
//
//  Created by 何文虎 on 2018/12/5.
//  Copyright © 2018年 何文虎. All rights reserved.
//

#import "WKCommentView.h"

CGFloat maxLabelHeight = 0; // 根据具体font而定
@implementation WKCommentView

- (instancetype)initWithFrame:(CGRect)frame{
    if (self == [super initWithFrame:frame]) {
        [self setup];
    }
    return self;
}

- (void)setup{
    
    self.backgroundColor = UIColorFromHex(0xF4F4F4);
    
    self.iconView = [[UIImageView alloc]init];
    self.commentLb = [[UILabel alloc]init];
    
    [self wh_addSubviews:@[self.iconView,self.commentLb]];
    
    [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(8);
        make.top.mas_equalTo(8);
        make.size.mas_equalTo(CGSizeMake(47, 15));
    }];
    
//    self.iconView.sd_layout
//    .leftSpaceToView(self, 8)
//    .topSpaceToView(self, 8)
//    .widthIs(47)
//    .heightIs(15);
    
    [self.commentLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(8);
        make.top.mas_equalTo(30);
        make.right.mas_equalTo(-8);
        make.bottom.mas_equalTo(-14);
    }];
//    self.commentLb.sd_layout
//    .leftSpaceToView(self, 8)
//    .topSpaceToView(self, 30)
//    .rightSpaceToView(self, 8)
//    .autoHeightRatio(0);
    
    _commentLb.font = PFSC_RegularFont(12);
    _commentLb.textColor = UIColorFromHex(0x3c3c3c);
    _commentLb.numberOfLines = 3;
    [_commentLb sizeToFit];
//    if (maxLabelHeight == 0) {
//        maxLabelHeight = _commentLb.font.lineHeight * 3;
//    }
    
    _iconView.backgroundColor = [UIColor redColor];
    _commentLb.backgroundColor = [UIColor yellowColor];
 
}

- (void)setCommentStr:(NSString *)commentStr{
    _commentStr = commentStr;
    _commentLb.text = BLANKSTRING(commentStr);
    if (commentStr.length<=0) {
        [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(0);
        }];
    }
//    self.height = 35 + 15 + maxLabelHeight;
    
    
}

@end
